using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DataHelper.BLL
{
    public class UserProfile
    {
        public int UserId { get; set; }
        public string UserName { get; set; }

        #region UserProfileSelectAll
        public static List<UserProfile> UserProfileSelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.UserProfile.UserProfileSelectAll(strSearch,top,bottom,ConnectionString);
            List<UserProfile> UserProfileList = new List<UserProfile>();
            while(dr.Read())
            {
                UserProfile myUserProfile = new UserProfile
                {
                    UserId = !dr.IsDBNull(dr.GetOrdinal("UserId")) ? (int)dr["UserId"] : 0,
                    UserName = !dr.IsDBNull(dr.GetOrdinal("UserName")) ? (string)dr["UserName"] : null
                };
                UserProfileList.Add(myUserProfile);
        }
        dr.Close();
        dr.Dispose();
        return UserProfileList;
        }
        #endregion
        #region UserProfileSelectRow
        public static UserProfile UserProfileSelectRow(int UserId, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.UserProfile.UserProfileSelectRow(UserId, ConnectionString);
            UserProfile userprofile = null;

            if(dr.Read())
            {
                userprofile= new UserProfile
                {
                    UserId = !dr.IsDBNull(dr.GetOrdinal("UserId")) ? (int)dr["UserId"] : 0,
                    UserName = !dr.IsDBNull(dr.GetOrdinal("UserName")) ? (string)dr["UserName"] : null,

                };
            }
        dr.Close();
        dr.Dispose();
        return userprofile;
        }
        #endregion
        #region UserProfileInsertRow
        public static void UserProfileInsertRow(string UserName, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.UserProfile.UserProfileInsertRow(UserName, ConnectionString);
        }
        #endregion
        #region UserProfileUpdateRow
        public static void UserProfileUpdateRow(int UserId, string UserName, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.UserProfile.UserProfileUpdateRow(UserId, UserName, ConnectionString);
        }
        #endregion
        #region UserProfileDeleteRow
        public static void UserProfileDeleteRow(int UserId, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.UserProfile.UserProfileDeleteRow(UserId,ConnectionString);
        }
        #endregion
    }
}
